﻿-- =============================================
-- Script Template
-- =============================================
SELECT 
	  INVENTLOCATIONID AS ShopID
	, ITEMRANGEID AS DepartmentID
	, SUM(AMOUNTSALE) as 'AMOUNTSALE' -  -- Сумма реализации
	, SUM(OPTAMOUNTSALE) as OPTAMOUNTSALE -- Сумма оптовой реализации
	, SUM(RETURNAMOUNTSALE) as RETURNAMOUNTSALE -- Сумма возвратов
FROM RETAILCASHREPORTDETAILS
WHERE (TRANSDATE>='2011.09.01') AND (TRANSDATE<='2011.09.01')
GROUP BY INVENTLOCATIONID,ITEMRANGEID
